﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:AdminApi="clr-namespace:Microsoft.ApplicationServer.Caching.AdminApi;assembly=Microsoft.ApplicationServer.Caching.Management" 
    xmlns:MDCAdminTool="clr-namespace:MDCAdminTool;assembly=E4D.AppFabric.Entities" 
    xmlns:Entities="clr-namespace:E4D.AppFabric.Entities;assembly=E4D.AppFabric.Entities" >

   <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="Images.xaml" />
   </ResourceDictionary.MergedDictionaries>

    <HierarchicalDataTemplate DataType="{x:Type MDCAdminTool:MdcCache}" ItemsSource="{Binding CacheRegions, IsAsync=True}" >
      <StackPanel Orientation="Horizontal">
         <Image Source="..\Resources\db.ico" Height="16" Width="16"  Margin="0,0,3,0"/>
         <TextBlock>
            Cache: <TextBlock Text="{Binding Name}" FontWeight="Bold"/>
         <TextBlock.ContextMenu>
               <ContextMenu>
                  <MenuItem Header="Add Cache Name"    Command="{StaticResource AddCacheName}"    CommandParameter="{Binding}" Icon="{StaticResource AddCache16}"/> 
                  <MenuItem Header="Remove Cache Name" Command="{StaticResource RemoveCacheName}" CommandParameter="{Binding}" Icon="{StaticResource RemoveCache16}"/>  
                  
                  <MenuItem Header="Add Region"        Command="{StaticResource AddRegionCacheName}" CommandParameter="{Binding}" Icon="{StaticResource AddRegionCacheName16}"/>
                  <MenuItem Header="Add Data Cache Item"  Command="{StaticResource AddDataCacheItemCommand}" CommandParameter="{Binding}" Icon="{StaticResource DataCacheItem16}"/>
                  <MenuItem Header="Cache Name Config" Command="{StaticResource ConfigCacheName}" CommandParameter="{Binding}" Icon="{StaticResource GetHostConfig16}"/>
                   <Separator />
                  <MenuItem Header="Serach" Command="{StaticResource SearchDataCacheCommand}" CommandParameter="{Binding}" Icon="{StaticResource GetHostConfig16}"/>
               </ContextMenu>
            </TextBlock.ContextMenu>
         </TextBlock>
      </StackPanel>
   </HierarchicalDataTemplate>

   <DataTemplate x:Key="CacheNameContentTemplate" DataType="{x:Type MDCAdminTool:MdcCache}">
      <GroupBox Padding="15">
         <ScrollViewer>
            <Grid>
               <Grid.RowDefinitions>
                  <RowDefinition Height="30*" />
                  <RowDefinition Height="200*" />
                  <RowDefinition Height="30*" />
               </Grid.RowDefinitions>

               <StackPanel x:Name="spTitle" Grid.Row="0" Orientation="Horizontal" Margin="15,0,0,0">
                  <StaticResource ResourceKey="CacheImage"/>
                  <TextBlock Text="{Binding Name}" FontSize="32" FontWeight="Bold" Margin="15,0,0,0" />
                  <TextBlock x:Name="HeaderText" Text=" Cache Name" FontSize="32" FontWeight="Bold" />
               </StackPanel>

               <StackPanel Grid.Row="1" Margin="15">
                  <GroupBox Padding="15" Margin="0,0,0,25">
                     <GroupBox.Header>
                        <StackPanel Orientation="Horizontal">
                           <StaticResource ResourceKey="GetHostConfig16" />
                           <TextBlock Text="Cache Name Config" Margin="5,0,0,0"/>
                        </StackPanel>
                     </GroupBox.Header>
                     <Grid >

                        <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="Auto" />
                           <ColumnDefinition Width="Auto" />
                           <ColumnDefinition Width="Auto" />
                           <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                           <RowDefinition Height="Auto" />
                           <RowDefinition Height="Auto" />
                           <RowDefinition Height="Auto" />
                           <RowDefinition Height="Auto" />
                           <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Label Content="Name:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Grid.Row="0" IsReadOnly="True" Height="23" HorizontalAlignment="Left" Margin="3" Name="nameTextBox" Text="{Binding Path=Name}" VerticalAlignment="Center" Width="120" />

                                <Label Content="Eviction:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" ToolTip="{StaticResource Help-Desc-Eviction}"/>
                        <TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="evictionTextBox" Text="{Binding Path=Eviction}" VerticalAlignment="Center" Width="120" ToolTip="{StaticResource Help-Desc-Eviction}"/>

                        <Label Content="TTL:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" ToolTip="{StaticResource Help-Desc-TTL}"/>
                        <TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="tTLTextBox" Text="{Binding Path=TTL}" VerticalAlignment="Center" Width="120" ToolTip="{StaticResource Help-Desc-TTL}"/>

                        <Label Content="Is Expirable:" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" ToolTip="{StaticResource Help-Desc-IsExpirable}"/>
                        <CheckBox Content="" Grid.Column="3" Grid.Row="1" Height="16" HorizontalAlignment="Left" IsChecked="{Binding Path=IsExpirable}" Margin="3" Name="isExpirableCheckBox" VerticalAlignment="Center" Width="120" ToolTip="{StaticResource Help-Desc-IsExpirable}"/>

                        <Label Content="Is High Availability:" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <CheckBox Content="" Grid.Column="3" Grid.Row="0" Height="16" HorizontalAlignment="Left" IsChecked="{Binding Path=IsHighAvailability}" Margin="3" Name="isHighAvailabilityCheckBox" VerticalAlignment="Center" Width="120" />

                        <Label Content="Notifications Enabled:" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <CheckBox Content="" Grid.Column="3" Grid.Row="2" Height="16" HorizontalAlignment="Left" IsChecked="{Binding Path=NotificationsEnabled}" Margin="3" Name="notificationsEnabledCheckBox" VerticalAlignment="Center" Width="120" />

                        <Label Content="Cache Type:" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="3" Name="tTYpeextBox" Text="{Binding Path=CacheType}" VerticalAlignment="Center" Width="120" />

                     </Grid>
                  </GroupBox>
               </StackPanel>



               <StackPanel x:Name="spFooter" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,15,0">
                        <Button Height="23" Width="75" Margin="5,0,5,0" Content="Cancel" Command="{StaticResource TabClose}"/>
                  <Button Height="23" Width="75" Margin="5,0,5,0" Content="Save" Command="{StaticResource SaveCacheName}" CommandParameter="{Binding}"/>
               </StackPanel>
            </Grid>
         </ScrollViewer>
      </GroupBox>
   </DataTemplate>
   
   <DataTemplate DataType="{x:Type AdminApi:CacheInfo}">
      <StackPanel Orientation="Horizontal">
         <TextBlock Text="Cache Name:" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding CacheName}" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="HostRegionMap :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding HostRegionMap}"  FontWeight="Bold" Margin="5,0,10,0"/>


      </StackPanel>
   </DataTemplate>

   <DataTemplate DataType="{x:Type MDCAdminTool:NamedCacheStats}">
      <StackPanel Orientation="Horizontal">
         <TextBlock Text="ItemCount:" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding ItemCount}" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="MissCount :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding MissCount}"  FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="RegionCount :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding RegionCount}"  FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="RequestCount :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding RequestCount}"  FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="Size :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding Size}"  FontWeight="Bold" Margin="5,0,10,0"/>

      </StackPanel>
   </DataTemplate>

   <DataTemplate DataType="{x:Type Entities:CacheConfig}">
      <StackPanel Orientation="Horizontal">
         
         <TextBlock Text="Cache Name:" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding CacheName }" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="Eviction Type :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding EvictionType  }" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="Is Expirable :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding IsExpirable }" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="Notifications Enabled :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding NotificationsEnabled }" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="Secondaries:" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding Secondaries }" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="TTL :" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding TTL }" FontWeight="Bold" Margin="5,0,10,0"/>

         <TextBlock Text="Type:" Margin="5,0,10,0"/>
         <TextBlock Text="{Binding Type }" FontWeight="Bold" Margin="5,0,10,0"/>
      </StackPanel>
   </DataTemplate>
   
   <DataTemplate DataType="{x:Type MDCAdminTool:PowerShellCommand}">
      <TextBlock Name="tbMessage"
         Text="{Binding Command }"
         FontWeight="Bold" Margin="5,0,10,0" Foreground="Green" >
         <TextBlock.ToolTip>
            <ToolTip Width="300" Height="Auto" >
               <TextBlock Text="{Binding Tooltip}" TextWrapping="WrapWithOverflow"/>
            </ToolTip>
         </TextBlock.ToolTip>
      </TextBlock>
      <DataTemplate.Triggers>
         <DataTrigger Binding="{Binding IsError}" Value="True">
            <Setter TargetName="tbMessage" Property="Foreground" Value="Red" />
         </DataTrigger>
      </DataTemplate.Triggers>
   </DataTemplate>
   
   <DataTemplate DataType="{x:Type MDCAdminTool:ErrorMessage}">
      <TextBlock Text="{Binding Message }"
                 FontWeight="Bold" Margin="5,0,10,0" Foreground="Red" >
         
      </TextBlock>
   </DataTemplate>
   
</ResourceDictionary>